package org.huzhp.gateway.service.impl;

import org.huzhp.gateway.service.AbstractAuditLogService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.text.SimpleDateFormat;
import java.util.Map;
import java.util.concurrent.ExecutorService;


/**
 * @Description: log4j类
 * @Author: huzp
 * @CreateDate: 2020/4/13 12:52
 * @Version: 1.0
 */
public class Log4jAuditLogService extends AbstractAuditLogService {

    public Log4jAuditLogService(ExecutorService executor) {
        super(executor);
    }

    @Override
    public void auditLog(Map<String, Object> message) {
        logger.info("\n请求路由:{}\n请求id:{}\n请求时间戳:{}\n请求ip:{}\n请求服务器:{}\n请求浏览器:{}\n版本号:{}\n是否移动设备:{}\n请求地址:{}\n请求方法:{}\n响应状态码:{}\n响应信息:{}\n请求耗时:{}ms",
                message.get("logRoute"),
                message.get("logRequestId"),
                sdf.format(message.get("logTime")),
                message.get("logIp"),
                message.get("logSystem"),
                message.get("logBrower"),
                message.get("logVersion"),
                message.get("logMobile"),
                message.get("logUrl"),
                message.get("logMethod"),
                message.get("logStatus"),
                message.get("logMessage"),
                message.get("logTook")!=null?message.get("logTook"):"");
    }


}
